﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq.Expressions;
using System.Text;
using Dapper;
using AgileLabs.Dapper.FluentMap;

namespace FocusCareer.Repositories
{
    public class BaseRepository : IBaseRepository
    {
        private readonly CommandDbConnection _commandDbConnection;
        private readonly QueryDbConnection _queryDbConnection;
        private IDbConnection _commandConn => _commandDbConnection.DbConnection;
        private IDbConnection _queryConn => _queryDbConnection.DbConnection;
        public Guid ConnectionId { get; private set; }

        public BaseRepository(QueryDbConnection queryDbConnection, CommandDbConnection commandDbConnection)
        {
            _queryDbConnection = queryDbConnection;
            _commandDbConnection = commandDbConnection;
            ConnectionId = Guid.NewGuid();
        }
        public void Commit()
        {
            throw new NotImplementedException();
        }

        public bool Delete<T>(T obj) where T : class
        {
            throw new NotImplementedException();
        }

        public bool DeleteAll<T>() where T : class
        {
            throw new NotImplementedException();
        }

        public bool DeleteMultiple<T>(Expression<Func<T, bool>> predicate) where T : class
        {
            throw new NotImplementedException();
        }

        public void Dispose()
        {
            throw new NotImplementedException();
        }

        public T Get<T>(int id, bool withCurrentTransacfion = false) where T : class
        {
            return withCurrentTransacfion ? _commandConn.Get<T>(id) : _queryConn.Get<T>(id);
        }

        public IEnumerable<T> GetAll<T>() where T : class
        {
            throw new NotImplementedException();
        }

        public object Insert<T>(T obj) where T : class
        {
            return _commandConn.Insert<T>(obj);
        }

        public void InsertList<T>(IEnumerable<T> list) where T : class
        {
            throw new NotImplementedException();
        }

        public void Rollback()
        {
            throw new NotImplementedException();
        }

        public bool Update<T>(T obj) where T : class
        {
            throw new NotImplementedException();
        }

        public void UpdateList<T>(IEnumerable<T> list) where T : class
        {
            throw new NotImplementedException();
        }
    }
}
